package events.event;

import java.awt.Point;
import java.util.ArrayList;
import java.util.HashMap;

import sprites.Sprite;
import sprites.characteristic.MonsterSpawn;
import sprites.characteristic.PlayerSpawn;

import events.CustomEvent;
import gui.GameCanvas;

public class MapLoadedEvent extends CustomEvent {

	private int height = 0;
	private int width = 0;
	private ArrayList<MonsterSpawn> monsterSpawn;
	private ArrayList<PlayerSpawn> playerSpawn;

	public MapLoadedEvent(Object data) {
		super(data);
	}

	public MapLoadedEvent(Object data, int width, int height, ArrayList<MonsterSpawn> monsterSpawn, ArrayList<PlayerSpawn> playerSpawn) {
		this(data);
		this.width = width;
		this.height = height;
		this.monsterSpawn = monsterSpawn;
		this.playerSpawn = playerSpawn;
	}

	@Override
	public void run(Object obj) {
		Object data = getData();
		if (data instanceof HashMap<?, ?>) {
			HashMap<Point, Sprite> map = (HashMap<Point, Sprite>) data;
			if (obj instanceof GameCanvas) {
				GameCanvas gc = (GameCanvas) obj;
				gc.addMap(map, height, width,monsterSpawn,playerSpawn);
			}
		} else {
			System.err.println("Something happend with sending map");
			System.exit(1);
		}
	}
}
